<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        Function.prototype.before = function(fn) {
            var _self = this;
            return function() {
                fn.apply(this, arguments); // console.log(1)
                return _self.apply(this, arguments) // console.log(2)
            }
        }
        Function.prototype.after = function(fn) {
            var _self = this;
            return function() {
                var ret = _self.apply(this, arguments); // console.log(1)和console.log(2)
                fn.apply(this, arguments); // console.log(3)
                return ret;
            }
        }
        var func = function() {
            console.log(2);
            return '你找的了我';
        }
        func = func.before(function() {
            console.log(1)
        }).after(function() {
            console.log(3)
        });
        console.log(func());
    </script>
</body>

</html>